import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { DeviceGridVO, DeviceGridForm, DeviceGridQuery } from '@/api/device/deviceGrid/types';

/**
 * 查询设备格子信息列表
 * @param query
 * @returns {*}
 */

export const listDeviceGrid = (query?: DeviceGridQuery): AxiosPromise<DeviceGridVO[]> => {
  return request({
    url: '/device/deviceGrid/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询设备格子信息详细
 * @param deviceGridId
 */
export const getDeviceGrid = (deviceGridId: string | number): AxiosPromise<DeviceGridVO> => {
  return request({
    url: '/device/deviceGrid/' + deviceGridId,
    method: 'get'
  });
};

/**
 * 新增设备格子信息
 * @param data
 */
export const addDeviceGrid = (data: DeviceGridForm) => {
  return request({
    url: '/device/deviceGrid',
    method: 'post',
    data: data
  });
};

/**
 * 修改设备格子信息
 * @param data
 */
export const updateDeviceGrid = (data: DeviceGridForm) => {
  return request({
    url: '/device/deviceGrid',
    method: 'put',
    data: data
  });
};

/**
 * 删除设备格子信息
 * @param deviceGridId
 */
export const delDeviceGrid = (deviceGridId: string | number | Array<string | number>) => {
  return request({
    url: '/device/deviceGrid/' + deviceGridId,
    method: 'delete'
  });
};

/**
 * 格子开锁
 * @param deviceGridId
 */
export const openDeviceGrid = (deviceGridId: string | number | Array<string | number>) => {
  return request({
    url: '/device/deviceGrid/open/' + deviceGridId,
    method: 'post'
  });
};
